//
//  StructDemo.swift
//  Swift3.0_Study
//
//  Created by chengfeng on 2016/10/14.
//  Copyright © 2016年 zhaochengfeng. All rights reserved.
//

import Cocoa

class StructDemo: NSObject {
    //结构体和类相似,区别不可以继承，修改自身变量需要 mutating 修饰
    
    struct Point {
        var x: Float
        var y: Float
        
        func printPoint() -> Void {
            print("x = \(self.x), y = \(y)")
        }
        
        mutating func changePoint(x: Float, y: Float) {
            self.x += x
            self.y += y
        }
        
        static func addXAndY(point : Point) {
            print("point.x + point.y = \(point.x + point.y)")
        }
    }
    
    func start() -> Void {
        
        var point1 = Point(x: 10, y: 15)
        point1.printPoint()
        
        point1.changePoint(x: 1, y: -1)
        point1.printPoint()
        
        Point.addXAndY(point: point1)
    }
    
    
}
